<script setup lang="ts">
import { getCurrentInstance } from 'vue'
import { onBeforeRouteLeave } from 'vue-router'
const { proxy } = getCurrentInstance()

/* ---- */
const WXConfig = proxy.$Store.get('WXConfig') || {}

/* --设置微信分享功能-- */
proxy.$WxTool.loadJsdk(WXConfig, (obj) => {
  if (!obj) return
  // ----
  obj.hideMenuItem()
})

/* ---- */
const items = [{
  show: true,
  child: [{
    show: true,
    isArrow: true,
    name: '分享设置',
    callback: () => { proxy.$Myfun.openPage(proxy, 'push', 'OfficeAdm') }
  }, {
    show: true,
    isArrow: true,
    name: '地方服务',
    callback: () => { proxy.$Myfun.openPage(proxy, 'push', 'OfficeList') }
  }, {
    show: true,
    isArrow: true,
    name: '广告图片',
    callback: () => { proxy.$Myfun.openPage(proxy, 'push', 'OfficeAdvs') }
  }]
}, {
  show: true,
    child: [{
    show: true,
    isArrow: true,
    name: '预览分享',
    callback: () => { proxy.$Myfun.openPage(proxy, 'push', 'OfficeShare') }
  }]
}]

/* ---- */
const getAuditFun = (type, item) => {
  switch (Number(type)) {
    case 1: {
      item.callback && item.callback(item)
      break
    }
  }
}

/* ---- */
onBeforeRouteLeave(() => { proxy.$Myfun.setScrollTop(proxy.$refs.formSection) })
</script>

<template>
  <div class="mescroll-touch" ref="formSection">
    <ul class="userSys xw-flex xw-flex-column">
      <template v-for="(item, index) in items">
      <li v-if="item.show">
        <template v-for="(son, num) in item.child">
        <a class="xw-Tfg xw-flex xw-flex-align" @click="getAuditFun(1, son)" v-if="son.show">
          <div class="USS-title xw-flex-W1">{{son.name}}</div>
          <i class="fal fa-angle-right" v-if="son.isArrow"></i>
        </a>
        </template>
      </li>
      </template>
    </ul>
  </div>
</template>
